
module.exports = function(app) {
  var express = require('express');
  var loginState = require('../fixtures/loginState');
  var loginStateRouter = express.Router();

  loginStateRouter.get('/state', function(req, res) {
      res.send(loginState.state);
  });

	loginStateRouter.get('/out', function(req, res) {
		loginState.logout();
		res.redirect("/");
	});

	loginStateRouter.post('/do', function(req, res){
		// if (req.query.success) {
		loginState.login();
		res.json({"state":"FULL","message":"NO_MESSAGE","wtg":null,"showCaptcha":false,"userState":{"logined":true,"user":{"id":1,"email":"admin@m3958.com","mobile":null,"name":"admin","level":0,"displayName":"admin","roles":[{"id":1,"name":"ROLE_PERSON_MANAGER"},{"id":2,"name":"ROLE_USER"}]},"allRoles":[{"id":4,"name":"ROLE_APP_DATA_CHANGE_FIX_RATE"},{"id":2,"name":"ROLE_USER"},{"id":5,"name":"ROLE_NOT_EXIST"},{"id":1,"name":"ROLE_PERSON_MANAGER"}]}});
		// } else {
		// 	res.json({"state":"ANONYMOUS","message":"USERNAME_PASSWORD_NOT_MATCH","wtg":null,"showCaptcha":false,"userState":null});
		// }
	});
  app.use('/login', loginStateRouter);
};
